package com.hippo.core.controller;

import com.alibaba.fastjson.JSONObject;
import com.hippo.core.config.annotation.RequiresPermissions;
import com.hippo.core.service.PlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: hippo
 */
@RestController
public class PlanController {
    @Autowired
    private PlanService planService;

    @RequiresPermissions("plan:list")
    @PostMapping("/getPlanList")
    public JSONObject getPlanList(@RequestBody JSONObject obj) {
        return planService.getPlanList(obj);
    }

    @RequiresPermissions("plan:add")
    @PostMapping("/addPlan")
    public JSONObject addPlan(@RequestBody JSONObject data) {
        return planService.addPlan(data);
    }

    @RequiresPermissions("plan:delete")
    @DeleteMapping("/deletePlan/{id}")
    public JSONObject deletePlan(@PathVariable String id) {
        return planService.deletePlan(id);
    }

    @RequiresPermissions("plan:update")
    @PutMapping("updatePlan")
    public JSONObject updatePlan(@RequestBody JSONObject data) {
        return planService.updatePlan(data);
    }

    @PostMapping("/getCaseListByIds")
    public JSONObject getCaseListByIds(@RequestBody JSONObject obj) {
        return planService.getCaseListByIds(obj);
    }

    @RequiresPermissions("plan:run")
    @PostMapping("/runPlan")
    public JSONObject runPlan(@RequestBody JSONObject obj) {
        return planService.runPlan(obj);
    }

    @GetMapping("/getPlanInfoById/{id}")
    public JSONObject getPlanInfoById(@PathVariable String id) {
        return planService.getPlanInfoById(id);
    }
}
